package com.atguigu.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisPlusConfig {
    /*
    *    向mybatisplus注册分页的拦截器
    *    分页拦截器作用：
    *       拦截住sql自动添加limit分页条件
    *
    *  PaginationInnerInterceptor: 分页的拦截器
    * */

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor mysqlPlusInterceptor = new MybatisPlusInterceptor();
        mysqlPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        return mysqlPlusInterceptor;
    }
}
